package com.csgc.camera.biz.other.activity

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle

import com.csgc.camera.base.BaseBindingActivity

import com.csgc.camera.util.AppUtil
import com.csgc.camera.util.clickWithTrigger
import com.cysd.spsyxj.R
import com.cysd.spsyxj.databinding.ActivityAboutBinding

import com.gyf.immersionbar.ktx.immersionBar


class AboutActivity: BaseBindingActivity<ActivityAboutBinding>(ActivityAboutBinding::inflate) {

    companion object{
        fun launch(context: Context){
            context.startActivity(Intent(context,AboutActivity::class.java))
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        immersionBar {
            fitsSystemWindows(true)
            //白色状态栏，黑色字体
            statusBarColor(R.color.white)
            statusBarDarkFont(true)
        }
        super.onCreate(savedInstanceState)
        binding.ivBack.clickWithTrigger { finish() }
        binding.tvVersion.text = "V${packageManager.getPackageInfo(packageName,0).versionName}"
        binding.tvChannelNum.text = AppUtil.getChannel()

        binding.layoutCallPhone.clickWithTrigger {
            callPhone("")
        }

        binding.tvBeiAn.clickWithTrigger {
            WebViewActivity.launch(this,"备案","https://beian.miit.gov.cn/")
        }
    }

    /**
     * 拨打电话（跳转到拨号界面，用户手动点击拨打）
     *
     * @param phoneNum 电话号码
     */
    fun callPhone(phoneNum: String) {
        val intent = Intent(Intent.ACTION_DIAL)
        val data = Uri.parse("tel:$phoneNum")
        intent.data = data
        startActivity(intent)
    }
}